# project data
NAME = climb_top
VERSION = 0.1
EXE = ${NAME}-${VERSION}

# compiler flags
CXXFLAGS = -Wall

# linker flags
SDL_LIB = -lSDL2 -lSDL2_image
LDFLAGS = ${SDL_LIB}

# engine
ENGINE = engine/

# files
SRC = $(wildcard *.c)
OBJ = ${SRC:.c=.o}
HEADERS = $(wildcard ${ENGINE}*.h *.h)

# default target
all: ${EXE}

${EXE}: ${OBJ}
	${MAKE} -C ${ENGINE}
	${CC} $^ ${ENGINE}*.o ${LDFLAGS} -o $@

# compile each file individually
.c.o:
	${CC} -c -o ${<:.c=.o} $< ${CXXFLAGS} -I ${ENGINE} -I .

# all objects depend on all headers (for now)
${OBJ}: ${HEADERS}

# remove all generated files
clean:
	-rm -f ${OBJ} ${EXE}

# remove all generated files, including from submodules
clean_all:
	${MAKE} -C ${ENGINE} clean
	-rm -rf ${OBJ} ${EXE}

.PHONY: clean clean_all
